/*
 * MHttpConnItem.java
 *
 * Created on April 16, 2008, 9:08 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package uns.fit.gis.httpconnection;

/**
 *
 * @author pham hiep
 */
public class MHttpConnItem{
    private boolean aborted;
    private boolean post;
    private byte data[];
    private int itemID;
    private String session;
    private MHttpConnectionHandler handler;
    private String url;
    private int reference;
    private boolean useSession;
    
    
    /** Creates a new instance of MHttpConnItem */
    public MHttpConnItem(int itemID, MHttpConnectionHandler _handler, String _url, boolean _isUseSession, boolean _post, byte[] _data) {
        setPost(_post);
        setAborted(false);
        setItemID(itemID);
        setSession("");
        setUseSession(_isUseSession);
        this.setUrl(_url);
        this.setHandler(_handler);
        this.data=_data;
    }
    
    /**
     * Get the status of connection aborted or non-aborted.
     * @return The boolean is true or false
     */
    public boolean isAborted() {
        return aborted;
    }
    
    /**
     * Set the status connection aborted or non-aborted.
     * @param aborted The status connection is true or false.
     */
    public void setAborted(boolean aborted) {
        this.aborted = aborted;
    }
    
    /**
     * Get the set POST data of connection.
     * @return The current POST data
     */
    public byte[] getData() {
        return data;
    }
    
    /**
     * Set POST data of request.
     * @param _data The array of bytes, represent the POST data
     */
    public void setData(byte[] _data) {
        this.data = _data;
    }
    
    /**
     * Get the ID of item.
     * @return The ID of item
     */
    public int getItemID() {
        return itemID;
    }
    
    /**
     * Set the ID of the item.
     * @param _itemID The ID of the item
     */
    public void setItemID(int _itemID) {
        this.itemID = _itemID;
    }
    
    /**
     * Get the session of the connection.
     * @return The session.
     */
    public String getSession() {
        return session;
    }
    
    /**
     * Set the session of the connection.
     * @param _session The session.
     */
    public void setSession(String _session) {
        this.session = _session;
    }
    
    /**
     * Get the handler of the item.
     * @return The handler.
     */
    public MHttpConnectionHandler getHandler() {
        return handler;
    }
    
    /**
     * Set the handler for the item.
     * @param handler The handler.
     */
    public void setHandler(MHttpConnectionHandler handler) {
        this.handler = handler;
    }
    
    /**
     * Get the URL of connection.
     * @return The URL string
     */
    public String getUrl() {
        return url;
    }
    
    /**
     * Set the URL of the request.
     * @param url The URL string
     */
    public void setUrl(String url) {
        this.url = url;
    }
    
    /**
     * Determine if the connection is a POST request.
     * @return true if it is a POST request
     */
    public boolean isPost() {
        return post;
    }
    
    /**
     * Set the connection is a POST request or not
     * @param post true if it is a POST request
     */
    public void setPost(boolean post) {
        this.post = post;
    }
    
    /**
     * Determine the connection use the session ID saved on cookie.
     * @return true if the connection use the session ID
     */
    public boolean isUseSession() {
        return useSession;
    }
    
    /**
     * Set the session ID to be used by this connection or not.
     * @param useSession true if this connection use the sesion ID
     */
    public void setUseSession(boolean useSession) {
        this.useSession = useSession;
    }

    public int getReference() {
        return reference;
    }

    public void setReference(int reference) {
        this.reference = reference;
    }
}
